#include<iostream>
#include<vector>
using namespace std;

vector<vector<int>> levelOrder(TreeNode* root) {
    vector<vector<int>> ret;
    if (root == nullptr)
        return ret;

    queue<TreeNode*>q;
    q.push(root);

    while (q.size())
    {
        int n = q.size();
        ret.push_back(vector <int>());
        while (n--)
        {
            TreeNode* temp = q.front();
            q.pop();
            ret.back().push_back(temp->val);
            if (temp->left != nullptr)
                q.push(temp->left);
            if (temp->right != nullptr)
                q.push(temp->right);
        }
    }
    return ret;
}

int main()
{
    return 0;
}